package com.anti.modular.bus.busmeansoftransaction.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.busmeansoftransaction.param.BusMeansOfTransactionParam;
import com.anti.modular.bus.busmeansoftransaction.service.BusMeansOfTransactionService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;

/**
 * 交易方式控制器
 *
 * @author anti
 * @date 2021-04-08 19:35:07
 */
@RestController
@RequestMapping("busMeansOfTransaction")
public class BusMeansOfTransactionController {

    @Resource
    private BusMeansOfTransactionService busMeansOfTransactionService;

    /**
     * 查询交易方式
     *
     * @author anti
     * @date 2021-04-08 19:35:07
     */
    @GetMapping("page")
    @BusinessLog(title = "交易方式_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam, BusMeansOfTransactionParam busMeansOfTransactionParam) {
        return Result.data(busMeansOfTransactionService.page(pageParam,busMeansOfTransactionParam));
    }

    /**
     * 添加交易方式
     *
     * @author anti
     * @date 2021-04-08 19:35:07
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "交易方式_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BusMeansOfTransactionParam.add.class) BusMeansOfTransactionParam busMeansOfTransactionParam) {
            busMeansOfTransactionService.add(busMeansOfTransactionParam);
        return Result.success("新增成功");
    }

    /**
     * 删除交易方式
     *
     * @author anti
     * @date 2021-04-08 19:35:07
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "交易方式_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BusMeansOfTransactionParam.delete.class) BusMeansOfTransactionParam busMeansOfTransactionParam) {
            busMeansOfTransactionService.delete(busMeansOfTransactionParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑交易方式
     *
     * @author anti
     * @date 2021-04-08 19:35:07
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "交易方式_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BusMeansOfTransactionParam.edit.class) BusMeansOfTransactionParam busMeansOfTransactionParam) {
            busMeansOfTransactionService.edit(busMeansOfTransactionParam);
        return Result.success("修改成功");
    }

    /**
     * 查看交易方式
     *
     * @author anti
     * @date 2021-04-08 19:35:07
     */
    @GetMapping("detail")
    @BusinessLog(title = "交易方式_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public Result detail(@Validated(BusMeansOfTransactionParam.detail.class) BusMeansOfTransactionParam busMeansOfTransactionParam) {
        return Result.data(busMeansOfTransactionService.detail(busMeansOfTransactionParam));
    }

    /**
     * 交易方式列表
     *
     * @author anti
     * @date 2021-04-08 19:35:07
     */
    @GetMapping("list")
    public Result list(BusMeansOfTransactionParam busMeansOfTransactionParam) {
        return Result.data(busMeansOfTransactionService.list(busMeansOfTransactionParam));
    }

}
